package aggregate.aggregator;

public class VerifyUpdatesThread extends Thread{
	
	private int flag;
	private Aggregator aggregator;
	
	/**************************************/
	
	public VerifyUpdatesThread(Aggregator aggregator)
	{
		super();
		this.flag = 0;
		this.aggregator = aggregator;
	}
	
	/**************************************/
	
	public void setFlag()
	{
		this.flag = 1;
	}
	
	/***************************************/
	
	public void resetFlag()
	{
		this.flag = 0;
	}
	
	/***************************************/
	
	public void run()
	{	
		
		while(this.flag == 0)
		{
			try 
			{
				Thread.sleep(10000);
				this.aggregator.verifyUpdates();
				for(int i=0; i<15; i++)
				{
					if(this.flag == 0)
						Thread.sleep(1000); 
					else
					{
						return;
					}
				}
                
            } catch (InterruptedException e)
            {
            	System.out.println(e.getMessage());
            }

		}
	}

	/***************************************/
}
